<%@taglib prefix="s" uri="/struts-tags"%>
<% 	String descargarFile=(String)request.getAttribute("descargarFile").toString(); 
	String messageDescarga=(String)request.getAttribute("messageDecarga").toString();
%>
<%@page import="pe.com.bbva.util.Constantes"%>
<%@taglib prefix="s" uri="/struts-tags"%> 
<s:form action="findAllReporteCRCPBP" id="consultaReporteCRCPBPForm"
	theme="simple" method="POST" enctype="multipart/form-data">
	<s:hidden name="idReporteControl" />
	<table width="100%">
		<tr>
		<td>
			<table width="100%">
			<tr>
				<td>
				<div id="pageTitle">Reporte CRC PBP</div>
				</td>
			</tr>
			<tr>
				<td>
				<table width="100%">
					<tr>
						<td colspan="2" align="center">
							<div >
							<fieldset class="fontfieldset">
							<legend class="fontlegend">Per&iacute;odo</legend>
								<table>
								<tr>
								<td class="label" align="left" >Reporte del <s:property value="descFechaCorte"/></td>
								</tr>
								</table>
							</fieldset>
							</div>
						</td>
						<td>&nbsp;&nbsp;&nbsp;</td>
						<td align="center">
							<div >
							<fieldset class="fontfieldset">
							<legend class="fontlegend">Reporte Historicos Guardados</legend>
								<table>
								<tr>
								<td class="label" align="left" >Fecha del Reporte:</td>
								<td>
									<s:select
									list="listFechasHistoricas" listKey="value" listValue="label"  theme="simple"
									id="cFechaHistorico"
									onchange="cargarHistoricoCRCPBP()" 
									name="fechaHistoricoCRCPBP" /> 
								</td>							
								</tr>
								</table>
							</fieldset>
							</div>
						</td>
					</tr>		
					<tr>
						<td>
							<s:submit value="Exportar a Excel" id="btnExportar" theme="simple" disabled="habilitaBotonGenRep"
							cssClass="ui-button ui-widget ui-state-default ui-corner-all"
							action="exportarReporteCRCPBP" /> 
							&nbsp;&nbsp;&nbsp;
							<s:submit value="Guardar Reporte en Historicos" id="btnGuardar" theme="simple"
							cssClass="ui-button ui-widget ui-state-default ui-corner-all"
							action="guardarHistoricoCRCPBP" /> 
							&nbsp;&nbsp;&nbsp;
							<s:submit value="Actualizar Formulario" 
 									id="bActFormulario" action="actualizarCRCPBP" 
 									theme="simple" cssClass="ui-button ui-widget ui-state-default ui-corner-all"/>&nbsp;
								&nbsp;&nbsp;
								<% if(descargarFile.equals(Constantes.REP_TERMINO)){%>
								<img src="images/xls.png" alt="download" border="0" />
								<a href="javascript:descargarExcel();">
										<%=messageDescarga%>
								</a>
								<% } %>
						</td>
						<td>
						</td>
					</tr>				
					
				</table>
				</td>
			</tr>
			</table>
		</td>
		</tr>
		<tr>
			<td>
			<table width="100%">
				<tr>
					<td align="center">
						<fieldset class="fontfieldset">
						<legend class="fontlegend">Reporte Comisiones CRC y PBP</legend>
						<table id="dataTable" width="100%"></table>
						 <div id="tablePager"></div>
						 </fieldset>
					</td>
				</tr>
			</table>
			</td>
		</tr>
	</table>
</s:form>
<div style="width: 100%; padding: 10px 10px 10px 10px;">

</div>

 
<script language="JavaScript" type="text/javascript">
	$(document).ready(function() {
		$("#consultaReporteCRCPBPForm").validationEngine();
   	   	$("thead tr th").attr("class","standardTable_Header_footer");
	   	$("caption").attr("class","standardTable_Header_footer caption");
	   	$("#btnLimpiar").click(function(){
    			limpiarForm();
    	});
    	
    	    jQuery("#dataTable").jqGrid({
		   	url:'./findAllReporteCRCPBP.do',
			datatype: "json",
		   	colNames:['ID','Cliente','TC','TNC','Nombre Cliente','Numero FMV','Moneda','C.R.C.','P.B.P.','Total'],
		   	colModel:[
		   		{name:'id',index:'id',hidden:true},
		   		{name:'codigoCliente',index:'codigoCliente', width:100,align:"center"},
		   		{name:'contratoConcesional',index:'contratoConcesional', width:180,align:"center"},
		   		{name:'contratoNoConcesional',index:'contratoNoConcesional', width:180,align:"center"},
		   		{name:'nombreCliente',index:'nombreCliente', width:150,align:"center"},
		   		{name:'nprestamofmv',index:'nprestamofmv', width:150,align:"center"},
		   		{name:'moneda',index:'moneda', width:150,align:"center"},
		   		{name:'comisionCRCConvert',index:'comisionCRCConvert', width:150,align:"right"},
		   		{name:'comisionPBPConvert',index:'comisionPBPConvert', width:150,align:"right"},
		   		{name:'sumComisionConvert',index:'sumComisionConvert', width:150,align:"right"}
		   	],
		   	rowNum:10,
		   	altRows : true,
			altclass : 'myAltRowClass',
		    width: 1070,
		   	rowList:[10,25,50],
		   	pager: '#tablePager',
		   	sortname: 'id',
		    viewrecords: true,
		    sortorder: "desc",
		    caption:"Reporte Comisiones CRC y PBP",
		    jsonReader : {
		      root:"dataModel",
		      repeatitems: false
		   },beforeRequest: function(){
		   		var _page=$(this).jqGrid('getGridParam', 'page');
		   		
		   		if(_page!=1){
					var _url=$(this).jqGrid('getGridParam', 'url');
					var _idx=_url.indexOf('?');
					
			 		$(this).jqGrid('setGridParam',{url:_url,page:_page});
				}
				
		   }
		});

	});
	function cargarHistoricoCRCPBP(){
		$("#consultaReporteCRCPBPForm").attr("action","./cargarHistoricoCRCPBP.do");
		$("#consultaReporteCRCPBPForm").submit();
	} 
	function descargarExcel(){		
		document.forms[0].action='downloadReporteCRCPBP.do';
		document.forms[0].submit();			
	}
</script>


